﻿using GENERIC.Respository.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;

namespace GENERIC.LinqToSqlRepository
{
    public class Transaction : ITransaction
    {
        #region Constructor

        public Transaction()
        {
            TransactionScope = new TransactionScope();
        }

        #endregion

        #region Properties

        protected TransactionScope TransactionScope { get; private set; }

        #endregion

        #region Methods

        public void Commit()
        {
            TransactionScope.Complete();
        }

        public void Rollback()
        {

        }

        public void Dispose()
        {
            if (TransactionScope != null)
            {
                TransactionScope.Dispose();
                TransactionScope = null;
                GC.SuppressFinalize(this);
            }
        }

        #endregion
    }
}
